package br.com.cardapiolivre.persistencia;

import br.com.cardapiolivre.entidades.Culinaria;
import br.com.cardapiolivre.entidades.Entidade;
import java.util.List;
import javax.persistence.Query;

/**
 *
 * @author juan
 */
public class CulinariaDaoJpa extends DaoJpa<Culinaria> {

    @Override
    public Culinaria consultar(Long id) throws Exception {
        try {
            return (Culinaria) em.find(Culinaria.class, id);
        } catch (Exception ex) {
            throw ex;
        }
    }

    @Override
    public List<Culinaria> consultar() throws Exception {
        try {
            Query q = em.createQuery("SELECT c FROM Culinaria c ");
            return q.getResultList();
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new Exception("Erro ao consultar culinária.");
        }
    }
    
}
